package org.tigris.scarab.model;

import java.io.Serializable;
import java.util.List;

/**
 * An Issue could has a  FederatedId with this format: {Domain}-{Code}{Id}
 * For example: collab.net-PACS1
 * The domain can also be null.
 * 
 * where
 *  Code = prefix
 *  Id = count
 *
 * @mbggenerated Mon Apr 11 17:57:15 CEST 2011
 */
public class Issue implements Serializable {

    private Long issueId; //SCARAB_ISSUE.ISSUE_ID
    /**
     * Typically this is equal to Module.code
     */
    private String prefix; //SCARAB_ISSUE.ID_PREFIX
    /**
     * Increment counter for the issue from 1 to N
     */
    private Integer count; //SCARAB_ISSUE.ID_COUNT
    private String domain; //SCARAB_ISSUE.ID_DOMAIN
    private IssueType issueType; //SCARAB_ISSUE.TYPE_ID
    private Module module; // FK SCARAB_ISSUE.MODULE_ID
    private Long createdTransId; //SCARAB_ISSUE.CREATED_TRANS_ID
    private Long lastTransId; //SCARAB_ISSUE.LAST_TRANS_ID
    private boolean deleted; //SCARAB_ISSUE.DELETED
    private boolean moved; //SCARAB_ISSUE.MOVED
    private String emailReferences; //SCARAB_ISSUE.EMAIL_REFERENCES
    private List<IssueAttributeValue> m_attributes;

    public Long getIssueId() {
        return issueId;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix == null ? null : prefix.trim();
    }

    public Integer getCount() {
        return count;
    }

    /**
     * The count must be &gt;= 1, if not return an IllegalArgumentException
     */
    public void setCount(int count) {
        if (count < 1) {
            throw new IllegalArgumentException("count must be >= 1");
        }
        this.count = count;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain == null ? null : domain.trim();
    }

    public IssueType getIssueType() {
        return issueType;
    }

//    public void setTypeId(Integer typeId) {
//        this.typeId = typeId;
//    }

    public Module getModule() {
        return module;
    }
//
//    public void setModuleId(Integer moduleId) {
//        this.moduleId = moduleId;
//    }

    public Long getCreatedTransId() {
        return createdTransId;
    }

    public void setCreatedTransId(Long createdTransId) {
        this.createdTransId = createdTransId;
    }

    public Long getLastTransId() {
        return lastTransId;
    }

    public void setLastTransId(Long lastTransId) {
        this.lastTransId = lastTransId;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public boolean isMoved() {
        return moved;
    }

    public void setMoved(boolean moved) {
        this.moved = moved;
    }

    public String getEmailReferences() {
        return emailReferences;
    }

    public void setEmailReferences(String emailReferences) {
        this.emailReferences = emailReferences == null ? null : emailReferences.trim();
    }
    
    protected void setAttributes(List<IssueAttributeValue> attributes) {
        this.m_attributes = attributes;
    }

    public List<IssueAttributeValue> getAttributes() {
        return m_attributes;
    }
}